package restaraunt.rating.project;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.TableLayout;
import android.widget.TextView;

public class ViewFood extends Activity {
	
	TextView tSqi;
	TableLayout lMan;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.view_food);
		
		// Init. Variables
		FoodRating table = new FoodRating(this);
		
		// Init. Controls
		lMan = (TableLayout) findViewById(R.id.tlMain);
		
		// Acquire data from database then apply it to string
		table.open();
		String[][] db = table.getData();
		table.close();
		
		// Display contents on screen
		
		/* This is a clunky way to print the database contents. This will be revised
		 * to create new labels within the table so the information will be better organized.
		 * 
		 * My intention is also to make this an abbreviated list that will reveal the full
		 * details when a particular line has been clicked on. On this screen only the food
		 * name, rating, and restaurant of origin should be shown.
		 */
		
		int y;
		TextView curView;
		for (y = 0; y < db.length; y++)
		{
			/* If possible, add click events to these that will display information about
			 * this entry on another screen, with an option to delete it. The specialized
			 * OnClick theNewBoston introduced that calls up a dialog box might come in
			 * handy here.
			 */
			
			curView = new TextView(this);
			curView.setId(y + 50);
			curView.setText(db[y][0] + "\t " + db[y][1] + " from " + db[y][4] + " (rated " + db[y][2] + "/5)\n");
			curView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
			((TableLayout) lMan).addView(curView);
		}
	}
	
	public void onClick(View v) {
		
		
		
	}
}
